//限制不得早于当前
// const limitStartDisabled = (date) => {
//   let now = (new Date()).getTime()
//   let other = date.getTime()
//   return other < now - 1000 * 60 * 60 * 24

import { getStore } from '@/utils/store'

// }
export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '项目名称',
			prop: 'projectName',
			type: 'textarea',
			maxlength: '50',
			showWordLimit: true,
			autosize: {
				minRows: 1,
			},
			span: 12,
			rules: [{ required: true, message: '请输入项目名称' }],
		},
		{
			label: '项目状态',
			prop: 'projectStatus',
			// propName: 'projectStatus',
			type: 'select',
			defaultValue: 0,
			dicData: [
				{
					label: '启用',
					value: 1,
				},
				{
					label: '停用',
					value: 0,
				},
			],
			addDisabled: true,
			rules: [{ required: true, message: '请选择项目状态' }],
			span: 12,
		},
		{
			label: '开始时间',
			prop: 'startTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			// 'disabled-date': limitStartDisabled,
			rules: [{ required: true, message: '请选择开始时间' }],
			span: 12,
		},
		{
			label: '结束时间',
			prop: 'endTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			// disabledDate: limitStartDisabled,
			rules: [{ required: true, message: '请选择结束时间' }],
			span: 12,
		},
	],
}

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '项目名称',
			prop: 'projectName',
			type: 'textarea',
			maxlength: '50',
			showWordLimit: true,
			autosize: {
				minRows: 1,
			},
			span: 6,
		},
		{
			label: '项目时间',
			prop: 'projectTimeBetween',
			type: 'dateBetween',
			format: 'YYYY年MM月DD',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 10,
		},
		{
			label: '项目状态',
			prop: 'projectStatus',
			type: 'select',
			dicData: [
				{
					label: '启用',
					value: 1,
				},
				{
					label: '停用',
					value: 0,
				},
			],
			span: 6,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		// { type: 'selection', reserveSelection: true },
		{ label: '项目名称', prop: 'projectName' },
		{ label: '服务承接单位', prop: 'organizationName' },
		{ label: '委托单位', prop: 'sampleTime' },
		{ label: '当前享受服务老人数', prop: 'serviceObjectNum' },
		{ label: '产生有效工单数', prop: 'orderNum' },
		{ label: '开始时间', prop: 'startTime' },
		{ label: '结束时间', prop: 'endTime' },
		{
			label: '项目状态',
			prop: 'projectStatus',
			custome: 'tag',
			dicData: [
				{
					label: '启用',
					value: 1,
					type: 'success',
				},
				{
					label: '停用',
					value: 0,
					type: 'danger',
				},
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_omProjectManagement_page',
	detail: 'view_omProjectManagement_view',
	add: 'view_omProjectManagement_add',
	edit: 'view_omProjectManagement_edit',
	delete: 'view_omProjectManagement_del',
	// authArea: 'authArea',
}
export const baseConfig = {
	pageName: '项目管理',
	dictcodes: [],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'projectName',
	exportMqTopic: '/ning/export/',
	api,
	auth: {
		...api,
	},
	paramsObj: {
		belongProject: 'govBuyManage',
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '服务承接单位',
			type: 'primary',
			operate: 'undertakingUnit',
			auth: api.edit,
			text: true,
			show: true,
		},
		{
			icon: 'editor',
			label: '委托单位',
			type: 'primary',
			operate: 'entrustingParty',
			auth: api.edit,
			text: true,
			show: true,
		},
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: api.edit,
			text: true,
			show: true,
		},
		{
			icon: 'detail',
			label: '详情',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
		{
			icon: 'editor',
			label: '规则设置',
			type: 'primary',
			operate: 'RuleSet',
			auth: api.index,
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: api.delete,
			text: true,
			show: true,
		},
	],
	beforeOnLoadFormate: async (params) => {
		return new Promise((resolve, reject) => {
			const userInfo = getStore('userInfo') || {}
			if (userInfo.classifyId == 3) {
				params.sourceType = 0
			}
			resolve({
				...params,
			})
		})
	},
	dialogConfig: {
		width: '75%',
	},
	searchConfig,
	formConfig,
	tableConfig,
	detailConfig: formConfig,
}
